package edu.ntu.im.p2ptrade.msg.handle;

import java.util.LinkedList;
import java.util.List;

import edu.ntu.im.p2ptrade.LockListener;
import edu.ntu.im.p2ptrade.P2PTrade;
import edu.ntu.im.p2ptrade.TransactionManager;
import edu.ntu.im.p2ptrade.msg.PMessage;
import net.jxta.endpoint.Message;

public class OKCommitHandle implements PMessageHandle {
	
	public void handle(Message msg) {
		String transactionId = msg.getMessageElement(P2PTrade.getInstance().getAppName(), PMessage.TRANSACTIONID).toString();
		String peer = msg.getMessageElement(P2PTrade.getInstance().getAppName(), PMessage.PEER).toString();
		if (peer.equals(P2PTrade.getInstance().getPeerName())){
			TransactionManager.getInstance().coordinator.meCanCommit = true;
		}else {
			TransactionManager.getInstance().coordinator.peerCanCommit = true;
		}
		
	}
}
